package com.ce.pms.custservice.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jmock.Mockery;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import com.ce.pms.DBUnitTool;
import com.ce.pms.base.vo.SearchVO;
import com.ce.pms.custservice.dao.ISubmitTaskDao;
import com.ce.pms.custservice.vo.SubmitTaskSearchVO;
import com.ce.pms.custservice.vo.SubmitTaskVO;
import com.ce.pms.exception.BusinessException;
import com.sitechasia.webx.core.support.Page;
/**
 * 功能描述: 部门协作单元测试类
 * <p>版权所有：中企动力
 * <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
 *
 * @author  胡煦
 * Create on:2008-12-23
 * Edit author:
 * Edit on:
 * 修改原因：

 */

public class SubmitTaskServiceImplT extends DBUnitTool {
	protected Mockery context = new Mockery();
	private IEventManageService eventManageService;
	private static ISubmitTaskService submitTaskService;
	private static ISubmitTaskDao submitTaskDao;
	@Before
	public void setUp() throws Exception
	{
		super.setUp();
		eventManageService = context.mock(IEventManageService.class);

	}


	@After
	public void tearDown() throws Exception
	{
		super.tearDown();
	}

	@Test
	/**
	 * 方法描述: 任务提交方法(可以多次)
	 * @author 胡煦
	 * Create on:2008-12-16
	 * @param csEventID，tasks
	 * @return SubmitTaskVO
	 * Edit author:
	 * Edit on:
	 * @param csEventID
	 * @param tasks
	 * @return SubmitTaskVO
	 * @roseuid 49436CB20251
	 * 修改原因：
	 */
	public void testAddTask() {
		Long csEventID = 1l;
		SubmitTaskVO taskVO = new SubmitTaskVO();
		taskVO.setCustServiceEventId(csEventID);
		taskVO.setCreator(1l);
		taskVO.setDeptName("测试部门");
		taskVO.setDeptPrincipalName("测试一号");
		taskVO.setEventNo("test001");
		Map<Long, List<String>> principalMap = new HashMap<Long, List<String>>();
		List<String> list = new ArrayList<String>();
		list.add("tester1");
		list.add("tester2");
		principalMap.put(1l, list);
		taskVO.setPrincipalMap(principalMap);
		List<Object[]> tasks  = submitTaskService.addTask(csEventID, taskVO);
	}
	@Test
	/**
	 * 方法描述: 任务自动提交方法
	 * @author 胡煦
	 * Create on:2008-12-16
	 * @param csEventID，tasks
	 * @return SubmitTaskVO
	 * Edit author:
	 * Edit on:
	 * @param csEventID
	 * @param tasks
	 * @return SubmitTaskVO
	 * @roseuid 49436CB20251
	 * 修改原因：
	 */
	public void testAutoAddTask() {
		Long csEventID = 1l;
		SubmitTaskVO taskVO = new SubmitTaskVO();
		taskVO.setCustServiceEventId(csEventID);
		taskVO.setCreator(1l);
		taskVO.setDeptId(1l);
		taskVO.setDeptName("测试部门");
		taskVO.setDeptPrincipalName("测试一号");
		taskVO.setEventNo("test001");
		taskVO = submitTaskService.autoAddTask(csEventID, taskVO);
	}

	/**
	 * 方法描述: 任务完工方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param submitTask
	 * @return SubmitTaskVO
	 * Edit author:
	 * Edit on:
	 * @param submitTask
	 * @roseuid 49436CB20290
	 */
	public void testDeptReply() {
		SubmitTaskVO submitTask = new SubmitTaskVO();
		submitTask = submitTaskService.deptReply(submitTask);
	}

	/**
	 * 方法描述: 催单方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param submitTaskID
	 * @return void
	 * @roseuid 49436CB2029F
	 */
	public void testHasten(Long submitTaskID) {
		Long submitTaskID1 = 1l;
		submitTaskService.hasten(submitTaskID);

	}

	/**
	 * 方法描述: 通知派工单处理中方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param submitTaskID
	 * @return void
	 * @roseuid 49436CB202BF
	 */
	public void testNoteDeptProcessing(Long submitTaskID) {
		Long submitTaskID1 = 1l;
		submitTaskService.noteDeptProcessing(submitTaskID);
	}

	/**
	 * 方法描述: 撤销任务方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param submitTaskVO
	 * @return void
	 * @roseuid 49436CB202CE
	 */
	public void testCancelTask() {
		SubmitTaskVO submitTaskVO = new SubmitTaskVO();
		submitTaskService.cancelTask(submitTaskVO);
	}

	/**
	 * 方法描述: 任务修改方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param submitTask
	 * @return SubmitTaskVO
	 * @param submitTask
	 * @roseuid 49436CB202FD
	 */
	public void testEditSubmitTask() {
		SubmitTaskVO submitTaskVO = new SubmitTaskVO();
		submitTaskService.cancelTask(submitTaskVO);
	}

	/**
	 * @param csEventID
	 * @param submitTaskVO
	 * @return SubmitTaskVO
	 * @roseuid 49436CB2034B
	 */
	public SubmitTaskVO testAutoAddTask(Long csEventID, SubmitTaskVO submitTaskVO) {
		return null;
	}

	/**
	 * 方法描述: 根据id获取SubmitTaskVO
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param id
	 * @return SubmitTaskVO
	 * @roseuid 49436CB20399
	 */
	public void testGetSubmitTaskVOById(Long id) {
		SubmitTaskVO submitTaskVO = submitTaskService.getSubmitTaskVOById(id);
	}

	/**
	 * 方法描述: 获取SubmitTaskVO列表
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param searchVO
	 * @return List<SubmitTaskVO>
	 * @roseuid 49436CB203B9
	 */
	public void testQuerySubmitTaskList() {
		SearchVO searchVO = new SearchVO();
		List<SubmitTaskVO> list = submitTaskService.querySubmitTaskList(searchVO);
	}

	/**
	 * 方法描述: 分页获取SubmitTaskVO列表
	 * @author 胡煦
	 * @param searchVO
	 * @return Page
	 * @roseuid 49436CB3001F
	 */
	public void testGuerySubmitTaskByPage() {
		SubmitTaskSearchVO searchVO = new SubmitTaskSearchVO();
		Page page = submitTaskService.querySubmitTaskByPage(searchVO);
		Assert.assertNotNull(page.getResult());
	}
	/**
	 * 方法描述: 通知派工单已经完工方法
	 * @author 胡煦
	 * Create on:2008-12-22
	 * @param taskId
	 * @return void
	 * Edit author:
	 * Edit on:
	 * 修改原因：
	 */
	public void testNoteDispatchFormComplete(Long taskId) {
		try {
			submitTaskService.noteDispatchFormComplete(taskId);
		} catch (BusinessException e) {
			e.printStackTrace();
			super.dealBusinessException(e, "custservice:custservice_parameter_null_exception");
		}
	}
	/**
    *
    * 功能描述:   <br>
    *
    * Create author：胡煦  <br>
    * Create on:2008-12-17  <br>
    * Edit author：  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
	@BeforeClass
	public static void initSubmitTask(){
		if (submitTaskService == null) {
			submitTaskService = (ISubmitTaskService)DBUnitTool.applicationContext.getBean("submitTaskService");
		}
		if (submitTaskDao == null) {
			submitTaskDao = (ISubmitTaskDao)DBUnitTool.applicationContext.getBean("submitTaskDao");
		}
	}

}
